import request from "@/utils/request";
import type { ResPage } from "./page";

export interface ResTrademark {
  id: number;
  tmName: string;
  logoUrl: string;
}

export type ResTrademarkByPage = ResPage<ResTrademark[]>;

export type ReqUpdateBaseTrademark = ResTrademark;

export type ReqSaveBaseTrademark = Omit<ResTrademark, "id">;

enum URLS {
  LIST = "/product/baseTrademark",
  ADD = "/product/baseTrademark/save",
  UPDATE = "/product/baseTrademark/update",
  DELETE = "/product/baseTrademark/remove",
}

/**
 * 请求品牌列表数据
 */
export function requestTrademarkListByPage(page = 1, limit = 5) {
  return request.get<any, ResTrademarkByPage>(`${URLS.LIST}/${page}/${limit}`);
}

// 添加品牌
export function requestSaveBaseTrademark(data: ReqSaveBaseTrademark) {
  return request.post<any, null>(URLS.ADD, data);
}

// 编辑品牌
export function requestUpdateBaseTrademark(data: ReqUpdateBaseTrademark) {
  return request.put<any, null>(URLS.UPDATE, data);
}

// 删除品牌
export function requestDeleteBaseTrademark(id: number) {
  return request.delete<any, null>(`${URLS.DELETE}/${id}`);
}
